package com.mallcloud.mall.app.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.mallcloud.mall.common.core.util.R;
import com.mallcloud.mall.product.api.entity.FloorModel;
import com.mallcloud.mall.product.service.FloorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "楼层信息管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/app/product/floor")
public class AppFloorController {
    private final FloorService floorService;

    @ApiOperation("列表查询")
    @GetMapping("/list")
    public R<List<FloorModel>> listName(FloorModel dto) {
        return R.ok(floorService.list(Wrappers.lambdaQuery(dto)
                .select(FloorModel::getFloorId, FloorModel::getName)
                .eq(FloorModel::getStatus, true)
                .orderByAsc(FloorModel::getSortOrder)
        ));
    }
}
